import time

from util_common import AdbUtil, PyUtil, OpenCVUtil


def test_reboot_normal(total_index=None):
    """重启压测"""
    AdbUtil.check_device_ready()
    image_name = f"{total_index:05d}.png "
    AdbUtil.screen_cap(image_name)
    # # 计算直方图相似度
    similarity = OpenCVUtil.compare_histograms(image_name, "origin.png")
    if similarity == 10:
        PyUtil.print_text(f"总次数{total_index} 图片异常")
        AdbUtil.reboot()
    else:
        if similarity > 0.9:
            PyUtil.print_text(f"总次数{total_index} 图片相同")
            AdbUtil.reboot()
        else:
            PyUtil.print_text(f"总次数{total_index} 图片不相同")
    # index = 1
    # while True:
    #     test_reboot_normal(index)
    #     index = index + 1


if __name__ == '__main__':

    # AdbUtil.click_by_send_event("event1",882,1396)
    AdbUtil.make_win_scope(20)